import Vue from 'vue'
import VueRouter from 'vue-router'
// 引入一级组件
import DashBoard from "../views/dashboard/dashboard"
//懒加载，点击的时候才需要加载，提升性能
const Home = () => import('../views/home/home');
const Category = () => import('../views/category/category');
const Cart = () => import('../views/cart/cart');
const Mine = () => import('../views/mine/mine');

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    // 重定向
    redirect: '/dashboard'
  },
  {
    // 一级路由，方便后续注册登录等功能
    path: '/dashboard',
    name: 'dashboard',
    component: DashBoard,
    children: [
      {
        path: '/dashboard',
        // 重定向到home
        redirect: '/dashboard/home'
      },
      {
        path: 'home',
        name: 'home',
        component: Home,
      },
      {
        path: 'category',
        name: 'category',
        component: Category,
      },
      {
        path: 'cart',
        name: 'cart',
        component: Cart,
      },
      {
        path: 'mine',
        name: 'mine',
        component: Mine,
      }
      
    ]

  }
]

const router = new VueRouter({
  routes
})

export default router
